#include <iostream>
#include <cstring>

using namespace std;

class Student {
    public:
        Student() : m_name(""), m_score(0.0) {}
        Student(char *name, float socre);
        Student(const Student &s);
        void show()const;
        void setName(const char *name);
    private:
        char *m_name;
        float m_score;
};

Student::Student(const Student &s)
{
    // 浅拷贝
    // this->m_name = s.m_name;
    // 深拷贝
    this->m_name = new char[strlen(s.m_name) + 1];
    strcpy(this->m_name, s.m_name);
    this->m_score = s.m_score;
}

Student::Student(char *name, float socre)
{
    m_name = new char[strlen(name) + 1];
    strcpy(m_name, name);
    m_score = socre;
}

void Student::show()const
{
    cout << "name:" << m_name << endl;
    cout << "score:" << m_score << endl;
}

void Student::setName(const char *name)
{
    strcpy(m_name, name);
}

int main(void)
{
    char buf[100] = "张三";

    Student s1(buf, 100);
    Student s2 = s1;

    strcpy(buf, "李四");

    s1.setName("王五");

    s1.show();
    s2.show();

    return 0;
}

